package cn.shenlong.front.action;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import cn.shenlong.portal.domain.Site;
import cn.shenlong.portal.service.SiteService;

@Controller
public class AboutAct {
	
	@Autowired
	private SiteService siteService;

	@RequestMapping(value = "/front/about", method = RequestMethod.GET)
	public String about(Integer id,HttpServletRequest request, ModelMap model) {
		Site site = siteService.findByPK(1l); 
		model.addAttribute("site", site);
		return "/front/about";

	}
	
	@RequestMapping(value = "/front/about2", method = RequestMethod.GET)
	public String abouts(Integer id,HttpServletRequest request, ModelMap model) {
		Site site = siteService.findByPK(1l); 
		model.addAttribute("site", site);
		return "/front/index";

	}
	@RequestMapping(value = "/front/test", method = RequestMethod.GET)
	public String test(Integer id,HttpServletRequest request, ModelMap model) {
		Site site = siteService.findByPK(1l); 
		model.addAttribute("site", site);
		return "/front/test";

	}
	
	/**
	 * 预览站点信息
	 * @param html
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/front/aboutShow")
	public String aboutShow(HttpServletRequest request,ModelMap model){
		String html=request.getParameter("html");
		if(!StringUtils.isBlank(html)){
			try {
				model.addAttribute("html", URLDecoder.decode(html,"UTF-8"));
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return "/front/aboutShow";
	}	
}
